import selfNaxios from 'utils/ajaxConfig.js';
import axios from 'axios';

export function getWorkGanttProgress (param, success, error) {
  return selfNaxios({
      method : 'get',
      url : '/projectInTeam/list',
      params: param
    }, success, error)
}

export function getWorkGanttTable (param, success, error) {
  return selfNaxios({
      method : 'get',
     // url : '/projectPlan/project',
     url : '/schedule/queryByPkProject',
      params: param
    }, success, error)
}

export function InsertWorkGanttItem (param, success, error) {
  return selfNaxios({
      method : 'post',
      url : '/projectPlan/insert',
      data: param
    }, success, error)
}

export function getWorkGanttManager (param, success, error) {
  return selfNaxios({
      method : 'get',
      url : '/projectPlan/search',
      params: param
    }, success, error)
}

export function deleteWorkGanttItem (param, success, error) {
  return selfNaxios({
      method : 'post',
   //   url : '/projectPlan/delete',
      url:'/schedule/delete',
      data: param
    }, success, error)
}

export function updateWorkGanttItem (param, success, error) {
  return selfNaxios({
      method : 'post',
      url : '/projectPlan/update',
      data: param
    }, success, error)
}

export function getWorkGanttDependName (param, success, error) {
  return selfNaxios({
      method : 'get',
      url : '/projectPlan/queryByRoot',
      params: param
    }, success, error)
}

export function getUserBaseDataUrl (param, success, error) {
  return selfNaxios({
      method : 'get',
      url : '/user/me',
      params: param
    }, success, error)
}

export function getDownloadExcel (param, success, error) {
  return selfNaxios({
      method : 'get',
      url : '/projectPlan/downLoad',
      params: param,
      responseType: 'blob'
    }, success, error)
}

export function onSubmitPlan (param, success, error) {
  return selfNaxios({
      method : 'post',
      //url : '/projectPlan/commit',
      url:'/schedule/commit',
      data: param
    }, success, error)
}

export function onWorkflowApprove (param, success, error) {
  return selfNaxios({
      method : 'post',
      url : '/workflow/approve',
      data: param
    }, success, error)
}

export function onWorkflowReject (param, success, error) {
  return selfNaxios({
      method : 'post',
      url : '/workflow/reject',
      data: param
    }, success, error)
}

export function onWorkflowPerson(param, success, error) {
  return selfNaxios({
      method : 'post',
      url : '/workflow/startWithAssign',
      data: param
    }, success, error)
}

export function onSearchHistoryList (param, success, error) {
  return selfNaxios({
      method : 'get',
      url : '/workflow/getApprovalRecord',
      params: param
    }, success, error)
}

export function onCheckApprovePerm (param, success, error) {
  return selfNaxios({
      method : 'get',
      url : '/workflow/checkApprovePerm',
      params: param
    }, success, error)
}


export function targetRefQuery (param) {
  return axios({
    method : 'get',
    url : '/measureIndex/refQuery',
    params: param,
    headers: {
        'Cache-Control': 'no-cache',
    },
  })
}
export function queryIndexOfPlan (param) {
  return axios({
    method : 'get',
    url : '/planIndex/queryIndexOfPlan',
    params: param,
    headers: {
        'Cache-Control': 'no-cache',
    },
  })
}

export function getExportProjectPlan(params) {
  return axios({
    method : 'get',
    url : '/projectPlan/export',
    params,
    headers: {
        'Cache-Control': 'no-cache',
    },
    responseType: 'arraybuffer' // 后台返回的数据流，必须设置该字段，要不然会乱码的哦
  })
}